package com.timer;

import com.entity.UserMetadata;
import com.service.UserOperator;
import com.util.LocalInformation;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Iterator;
import java.util.Map;

/**
 * Created by wlc on 2018/3/21.
 */
@Component
public class UserTimer {
    private static int userOperatorThreshold = 2700000;

    @Scheduled(fixedRate = 3600000)
    public void isOffline(){
        Iterator iter = UserMetadata.OnlineUserOperatorTime.entrySet().iterator();
        while (iter.hasNext()){
            Map.Entry entry = (Map.Entry) iter.next();
            if (Long.parseLong(LocalInformation.getTimeID())-Long.parseLong(entry.getValue().toString())>=userOperatorThreshold){
                UserOperator.log_out(entry.getKey().toString());
            }
        }
    }
}
